package com.klod.news.widget

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.TabPosition
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp

@Composable
fun MyCapsuleBackgroundIndicator(
    modifier: Modifier = Modifier,
    tabPositions: List<TabPosition>,
    selectedTabIndex: Int,
    color: Color
) {
    val currentTabPosition = tabPositions[selectedTabIndex]
    Box(
        modifier = modifier
            .offset {
//                val x = currentTabPosition.left.roundToPx()
                IntOffset(0, -15)
            }
            .width(currentTabPosition.width)
            .padding(horizontal = 4.dp)
            .height(35.dp)
            .clip(RoundedCornerShape(50))
            .background(color)
    )
}